﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OXY
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnTinh_Click(object sender, EventArgs e)
        {
            if (txtAx.Text == "" || txtAy.Text == "" || txtBx.Text == "" || txtBy.Text == "" || txtCx.Text == "" || txtCy.Text == "")
            {
                lblError.Visible = true;
                lblError.Text = "some field is blank";
            }
            else
            {
                lblError.Visible = false;
                Point A = new Point(float.Parse(txtAx.Text), float.Parse(txtAy.Text));
                Point B = new Point(float.Parse(txtBx.Text), float.Parse(txtBy.Text));
                Point C = new Point(float.Parse(txtCx.Text), float.Parse(txtCy.Text));
                Triangle T = new Triangle(A, B, C);
                double p = T.perimeter();
                double s = T.square();
                Point tt = T.center();
                lblChuVi.Text = p.ToString();
                lblDienTich.Text = s.ToString();
                lblTrongTam.Text = tt.toString();
            }
        }
    }
}
